package com.ezware.cleansweep.core.internal;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import com.ezware.cleansweep.core.Platform;

public class ApplicationMainFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	
	private Platform platform;
	
	private final class MainFrameListener extends WindowAdapter {
		public void windowClosing(WindowEvent e) {
			platform.exit();
		}
	}
	
	public ApplicationMainFrame( final Platform platform ) {
		
		super( platform.getApplication().getTitle() );
		setIconImage(platform.getApplication().getIcon());
		setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
		this.platform = platform;
		addWindowListener( new MainFrameListener());
		setContentPane( platform.getApplication().getContent());
		pack();
		
	}

}
